
let colNames = ['stuName', 'chinese', 'math', 'english', 'physics', 'chemistry', 'biology'];
let colNames_c = ['姓名', '语文', '数学', '英语', '物理', '化学', '生物', '总分'];

let names = ["Sophia", "Emma", "Olivia", "Ava", "Jackson", "Lucas", "Mason", "Caden", "Oliver", "Elijah",
              "陈枷秀", "孙淑然", "李欣然", "孙承霞", "张语", "魏子瑞", "邢语珊", "王赢雪", "孙一一", "孙佳惠"];
/**
 *  生成模拟数据
 */
export function makeTitle () {
  let cols = [];
  for ( let i = 0; i < colNames.length; i++ ) {
    let item = {
      prop: colNames[i],
      label: colNames_c[i],
      width: 120
    };
    cols.push(item);
  }
  return cols;
}

export function makeGrade () {
  let grades = [];
  // let number = randomNum(40, 150);
  // console.log(number);

  for ( let i = 0; i < 15; i++ ) {    // 生成15 条成绩数据
    let item = {};

    colNames.forEach(value => {
      if (value !== 'stuName' && value !== 'total') {
        item[value] = randomNum(40, 150);
      } else if (value === 'stuName') {
        let number = randomNum(0, 19);
        item[value] = names[number];
      }
    });
    grades.push(item);
  }

  return grades;
}


// 生成min 到 max之间的随机整数
function randomNum (min, max) {
  switch ( arguments.length ) {
    case 1:
      return parseInt(Math.random() * min + 1, 10);
    case 2:
      return parseInt(Math.random() * (max -min + 1) + min,10);
    default:
      return 0;
  }
}

export function getTitle () {
  let jsonstr =
    "[{\"prop\":\"stuName\",\"label\":\"姓名\",\"width\":120}," +
    "{\"prop\":\"chinese\",\"label\":\"语文\",\"width\":120}," +
    "{\"prop\":\"math\",\"label\":\"数学\",\"width\":120}," +
    "{\"prop\":\"english\",\"label\":\"英语\",\"width\":120}," +
    "{\"prop\":\"physics\",\"label\":\"物理\",\"width\":120}," +
    "{\"prop\":\"chemistry\",\"label\":\"化学\",\"width\":120}," +
    "{\"prop\":\"biology\",\"label\":\"生物\",\"width\":120}]";
  return JSON.parse(jsonstr);
}

export function getGradeList () {
  let jsonStr = "[{\"stuName\":\"Olivia\",\"chinese\":117,\"math\":64,\"english\":58,\"physics\":93,\"chemistry\":119,\"biology\":132}," +
    "{\"stuName\":\"张语\",\"chinese\":68,\"math\":135,\"english\":50,\"physics\":132,\"chemistry\":101,\"biology\":106}," +
    "{\"stuName\":\"张语\",\"chinese\":121,\"math\":140,\"english\":51,\"physics\":73,\"chemistry\":40,\"biology\":67}," +
    "{\"stuName\":\"孙一一\",\"chinese\":81,\"math\":97,\"english\":124,\"physics\":102,\"chemistry\":43,\"biology\":131}," +
    "{\"stuName\":\"Ava\",\"chinese\":108,\"math\":148,\"english\":59,\"physics\":61,\"chemistry\":58,\"biology\":101}," +
    "{\"stuName\":\"陈枷秀\",\"chinese\":78,\"math\":84,\"english\":103,\"physics\":64,\"chemistry\":93,\"biology\":145}," +
    "{\"stuName\":\"孙淑然\",\"chinese\":51,\"math\":63,\"english\":77,\"physics\":136,\"chemistry\":104,\"biology\":146}," +
    "{\"stuName\":\"王赢雪\",\"chinese\":118,\"math\":70,\"english\":148,\"physics\":48,\"chemistry\":79,\"biology\":93}," +
    "{\"stuName\":\"Lucas\",\"chinese\":139,\"math\":98,\"english\":143,\"physics\":114,\"chemistry\":46,\"biology\":57}," +
    "{\"stuName\":\"Olivia\",\"chinese\":127,\"math\":145,\"english\":118,\"physics\":121,\"chemistry\":49,\"biology\":114}," +
    "{\"stuName\":\"孙承霞\",\"chinese\":68,\"math\":139,\"english\":79,\"physics\":98,\"chemistry\":116,\"biology\":131}," +
    "{\"stuName\":\"Olivia\",\"chinese\":66,\"math\":112,\"english\":44,\"physics\":124,\"chemistry\":46,\"biology\":148}," +
    "{\"stuName\":\"孙一一\",\"chinese\":97,\"math\":61,\"english\":76,\"physics\":56,\"chemistry\":67,\"biology\":59}," +
    "{\"stuName\":\"孙淑然\",\"chinese\":129,\"math\":40,\"english\":136,\"physics\":115,\"chemistry\":55,\"biology\":73}," +
    "{\"stuName\":\"Caden\",\"chinese\":97,\"math\":99,\"english\":108,\"physics\":80,\"chemistry\":149,\"biology\":111}]";

  return JSON.parse(jsonStr);
}








